<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<?php
if(!isset($_SESSION)){
	session_start();
}

if(!isset($_SESSION["adminName"]) || (empty($_SESSION["adminName"]))){
	header ("Location: ../index.php");
}
?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Edit Page</title>
    <link href="../../Styles/adminstype.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/admin_script.js"></script>
</head>
<body>
<?php
	$TenLSP = "";
	$BiXoa = "";
	$checked = "";
	$id = $_SESSION["delete"];
	
	if(empty($_REQUEST["btnXoa"])){
		if($id != "") // kiem tra du lieu
		{
			$sql = "select * from hangsanxuat where MaHangSanXuat = $id";
				
			@require_once "../database/DataProvider.php";
			$result =  DataProvider::ExecuteQuery($sql);
				
			if(!empty($result))
			{
				while ($row=mysql_fetch_array($result)){
					$TenLSP = $row["TenHangSanXuat"];
					$BiXoa = $row["BiXoa"];
					$checked = ($row["BiXoa"] == 0 ? 'Đang hoạt động' : 'Đã bị xóa');
				}	
			}
		}
	}
?>
<table>
	<tr class="boxContentTitle">
		<td>Bạn chắc chắn muốn xóa?</td>
	</tr>
	<tr>
		<td>
			 <form action="resource/form_delete_manufacture.php" method="post" name="form_delete_manufacture">
				<table class="tableBoxView">
					<tr>
						<td style="width: 200px"><td>
						<td style="width: 200px">Tên loại sản phẩm</td>
						<td><?php echo($TenLSP);?></td>
					</tr>
					<tr>
						<td><td>
						<td>Bị xóa</td>
						<td><?php echo($checked);?></td>
					</tr>
					<tr>
						<td><td>
						<td></td>
						<td><input type="submit" name="btnXoa" value="Delete"/></td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
	<tr>
		<td>
			<?php
			if(!empty($_REQUEST["btnXoa"]))//có yeu cau xoa
			{
				if($id != "") //  kiểm tra 
				{
					$sql = "UPDATE hangsanxuat SET BiXoa=1 WHERE MaHangSanXuat=$id";
					require_once "../../database/DataProvider.php";
					$result =  DataProvider::ExecuteQuery($sql);
					echo($result);
				}
				header ("Location: ../admin_manager_manufacture.php");
			}
			?>
		</td>
	</tr>
</table>
</body>
</html>